package fs.component {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import fs.component.event.ComponentEvent;
	/**
	 * ...
	 * @author F.S.
	 */
	public class TextButton extends Sprite{
		private var _tf_title:TextField;
		private var _title:String;
		private var _onClick:Function;
		
		public function TextButton() {
			_tf_title = new TextField();
			_tf_title.selectable = false;
			_tf_title.border = true;
			_tf_title.autoSize = TextFieldAutoSize.LEFT;
			addChild(_tf_title);
			
			buttonMode = true;
			mouseChildren = false;
			
			addEventListener(MouseEvent.CLICK, onMouseClick, false, 0, true);
		}
		
		private function onMouseClick(e:MouseEvent):void {
			if (_onClick != null) {
				var event:ComponentEvent = new ComponentEvent(Event.CHANGE,this);
				_onClick.apply(null, [event]);
			}
		}
		
		public function get title():String {
			return _title;
		}
		
		public function set title(value:String):void {
			_tf_title.text = _title = value;
		}
		
		public function get onClick():Function {
			return _onClick;
		}
		
		public function set onClick(value:Function):void {
			_onClick = value;
		}
		
	}

}